<layout name='Layout/layout_main' />
<tagLib name="html" />
<script type="text/javascript">
	var manager = null;
	function add() {
		pid = $("#id").val();
		$("#form_data :text").each(function() {
			$(this).val("");
		});
		$("#form_data :text").each(function() {
			$(this).val("");
		});
		$("#pid").val(pid);
		$("#id").val('');
		$("#opmode").val("add");
	};

	function save() {
		if (check_form("form_data")) {
			sendForm("form_data", "{:U('node/save')}", fix_url("{:U('node/index')}?s_pid=" + $("#s_pid").val()));
		}
	}

	function test() {
		form_search.submit();
	};
	function select_pid() {
		winopen("{:U('winpop')}",730, 500);
	}

	function showdata(result) {
		for (var s in result.data) {
			set_val(s, result.data[s]);
		}
		$("#node_name").val($("#node_list option[value='" + $("#pid").val() + "']").text());
		$("#opmode").val("edit");
	}


	$(document).ready(function() {
		$(".sub_left_menu .tree_menu a").click(function() {
			$(".sub_left_menu .tree_menu  a").each(function() {
				$(this).attr("class", "");
			});
			$(this).attr("class", "active");
			sendAjax("{:U('read')}", "id=" + $(this).attr("node"), function(data) {
				showdata(data);
			});
			return false;
		})
		sendAjax("{:U('read')}", "id={$pid}", function(data) {
			showdata(data);
		});
	});

</script>
<div class="title panel panel-default">
	<div class="panel-body">
		<h3 class="col-md-12">节点管理</h3>
	</div>
</div>
<form name="form_search" method="post" action="">
	<div class="operate panel panel-default">
		<div class="panel-body">
			<div class="pull-left">
				<html:select  name="s_pid" id="s_pid" options='groupList' style="form-control" selected='pid'  change='test()'/>
			</div>
			<div class="pull-right">
				<a onclick="add();" class="btn btn-default">新增</a>
				<a onclick="save();"  class="btn btn-default">保存</a>
			</div>
		</div>
	</div>
</form>
<!-- 功能操作区域结束 -->
<!-- 列表显示区域  -->
<div class="row">
	<div class="col-md-4 sub_left_menu">
		<div class="well">
			<?php echo $menu ?>
		</div>
	</div>
	<div class="col-md-8 sub_content">
		<form id="form_data" name="form_data" method="post" class="well form-horizontal">
			<input type="hidden" name="id" id="id">
			<input type="hidden" name="ajax" id="ajax" value="1">
			<input type="hidden" name="opmode" id="opmode" value="">
			<html:select id="node_list" name="node_list"  options="node_list" style="display-none"/>
			<div class="form-group col-md-12">
				<label class="col-md-4 control-label" for="name">名称*：</label>
				<div class="col-md-8">
					<input class="form-control" type="text" id="name" name="name" check="require" msg="请输入名称">
				</div>
			</div>

			<div class="form-group col-md-12">
				<label class="col-md-4 control-label" for="url">地址：</label>
				<div class="col-md-8">
					<input class="form-control" type="text" id="url" name="url">
				</div>
			</div>

			<div class="form-group col-md-12">
				<label class="col-md-4 control-label" for="url">父节点：</label>
				<div class="col-md-8">
					<div class="input-group">
						<input name="node_name" class="form-control val" id="node_name" type="text"  source="{:U('dept/json')}" />
						<input name="pid" class="key" id="pid" type="hidden" msg="请选择父节点" check="require"  />
						<span class="input-group-btn">
							<button class="btn btn-default" onclick="select_pid()" type="button">
								选择
							</button> </span>
					</div>
				</div>
			</div>
			<div class="form-group col-md-12">
				<label class="col-md-4 control-label" for="sort">排序：</label>
				<div class="col-md-8">
					<input class="form-control" type="text" id="sort" name="short" check="require" msg="请输入简称">
				</div>
			</div>

			<div class="form-group col-md-12">
				<label class="col-md-4 control-label" for="is_del">状态*：</label>
				<div class="col-md-8">
					<select   name="is_del" id="is_del" class="form-control">
						<option  value="0">启用</option>
						<option value="1">禁用</option>
					</select>
				</div>
			</div>

			<div class="form-group col-md-12">
				<label class="col-md-4 control-label" for="remark" >备注：</label>
				<div class="col-md-8" >
					<textarea class="form-control" name="remark" rows="5" class="col-md-12" ></textarea>
				</div>
			</div>
		</form>
	</div>
</div>
